/**
/**** <p>Title: Ajax广泛应用</p>
* <p>Company: 北京福富软件技术股份有限公司福州分公司</p>
* @author huangjx
* @version 1.0
*/
//jtext 属性 domain 字段属性一样
String.prototype.trim= function(){  
    return this.replace(/(^\s*)|(\s*$)/g, "");  
}
String.prototype.replaceAll  = function(s1,s2){    
	return this.replace(new RegExp(s1,"gm"),s2);    
}
String.prototype.replaceString = function(s1,s2){
	this.str=this;
	if(s1.length==0)return this.str;
	var idx=this.str.indexOf(s1);
	while(idx>=0){
	this.str=this.str.substring(0, idx)+s2+this.str.substr(idx+s1.length);
	idx=this.str.indexOf(s1);
	}
	return this.str;
}
function StringBuffer()    
{    
    this._strings = [];    
    if(arguments.length==1)    
    {    
        this._strings.push(arguments[0]);    
    }    
}    
   
StringBuffer.prototype.append = function(str)    
{    
    this._strings.push(str);    
    return this;    
}    
   
StringBuffer.prototype.toString = function()    
{    
    return this._strings.join("");    
}    
   
/* 返回长度 */   
StringBuffer.prototype.length = function()    
{    
    var str = this._strings.join("");    
    return str.length;    
}    
   
/* 删除后几位字符 */   
StringBuffer.prototype.del = function(num)    
{    
    var len = this.length();    
    var str = this.toString();    
    str     = str.slice(0,len-num);    
    this._strings = [];    
    this._strings.push(str);    
}   

function $(id){//获得一个ID对象
	return document.getElementById(id);
}
function $$(obj,node,ind){//获得ID对象
    var  currInd=0;
    if(ind){
    	currInd=ind;
    }
	try{
		return obj.getElementsByTagName(node)[currInd].firstChild.nodeValue;
	}catch(e){return "";}
}
function getXmlValue(obj,node){//获得ID对象
	try{
		return obj.getElementsByTagName(node)[0].firstChild.nodeValue;
	}catch(e){return "";}
}
function $$$(obj,node,value){//设置节点值
    try{
		obj.getElementsByTagName(node)[0].firstChild.nodeValue=value;
	}catch(e){}
}
function newXMLHttpRequest() {//获取一个 XMLHttpRequest对像
  var xmlreq = false;
  if (window.XMLHttpRequest) {
    xmlreq = new XMLHttpRequest();

  } else if (window.ActiveXObject) {

    try {
      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) {
      try {
        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
        xmlreq = false;
      }
    }
  }

return xmlreq;
}
 function getReadyStateHandler(req, responseXmlHandler) {//返回一个 XMLHttpRequest对象实例
   return function () {
     if (req.readyState == 4) {
       if (req.status == 200) {
        responseXmlHandler(req);
       } else {
	       	 if(req.status!=500){
	       	    alert("HTTP error "+req.status+": "+req.statusText+"!");
	       	 }else{
	       	 	alert("HTTP error "+req.status+": "+req.statusText+"!");
	       	 }
       }
     }
   }
 }
function  getUrlParameter(url,formid){//把表单素组成一个链接
    var urlParameter=url;
    var formObj="";
    if(document.getElementById(formid)){
    	formObj=document.getElementById(formid)
    }else{
        formObj=document[formid];
    }
    var str=new StringBuffer();
    if(urlParameter.indexOf("?")==-1){
    	urlParameter+="?a1b1c1=1";
    }
    str.append(urlParameter);
	for(i=0;i<formObj.elements.length;i++){
		if(formObj.elements[i].type!="button"&&formObj.elements[i].type!="reset"&&formObj.elements[i].type!="submit"){
		    if(formObj.elements[i].type=="checkbox"||formObj.elements[i].type=="radio"){
		    	if(formObj.elements[i].checked==false) continue;
		    }
			if(formObj.elements[i]["name"]){
				str.append("&"+formObj.elements[i]["name"]+"="+encodeURIComponent(formObj.elements[i].value.trim()));
	    	}else{
	    		str.append("&"+formObj.elements[i].id+"="+encodeURIComponent(formObj.elements[i].value.trim()));
	    	}

		}

	}
	return str.toString();
	
}
function  getPostData(formid){//把表单素组成一个链接post提交，用来做大量参数传输
    var formObj="";
    if(document.getElementById(formid)){
    	formObj=document.getElementById(formid)
    }else{
        formObj=document[formid];
    }
    var str=new StringBuffer();
    str.append("X1X1X1=1");
	for(i=0;i<formObj.elements.length;i++){
		if(formObj.elements[i].type!="button"&&formObj.elements[i].type!="reset"&&formObj.elements[i].type!="submit"){
		    if(formObj.elements[i].type=="checkbox"||formObj.elements[i].type=="radio"){
		    	if(formObj.elements[i].checked==false) continue;
		    }
			if(formObj.elements[i]["name"]){
				str.append("&"+formObj.elements[i]["name"]+"="+(formObj.elements[i].value.trim()));
	    	}else{
	    		str.append("&"+formObj.elements[i].id+"="+(formObj.elements[i].value.trim()));
	    	}

		}

	}
	return str.toString();
	
}
/*表单可能是有多个对象组合的，要分批次填充，空值不填充*/
function  fillForm(obj,formid,times){//对象填充表单
	var formObj="";
    if(document.getElementById(formid)){
    	formObj=document.getElementById(formid)
    }else{
        formObj=document[formid];
    }
    if(!formObj)return;//表单对象不存在则返回
    if(obj){
		for(i=0;i<formObj.elements.length;i++){
			if(formObj.elements[i].type!="button"){
			    var value="";
			    if(formObj.elements[i]["name"]){
		    		value=$$(obj,formObj.elements[i]["name"].substring(formObj.elements[i]["name"].lastIndexOf(".")+1));
			    }else{
		    		value=$$(obj,formObj.elements[i].id);
			    }
			    if(formObj.elements[i].type=="radio"){
			    	if(formObj.elements[i].value==value){
			    		formObj.elements[i].checked=true;
			    	}
			    }else{
			        if(!times){
			    	formObj.elements[i].value=value;
			    	}else{
			    		if(value!=""){
			    			formObj.elements[i].value=value;
			    		}
			    	}
			    }
			}
		}
	}else{
		for(i=0;i<formObj.elements.length;i++){
		    if(formObj.elements[i].type!="button"&&formObj.elements[i].type!="radio"&&formObj.elements[i].type!="checkbox"){
				formObj.elements[i].value="";
			}
			if(formObj.elements[i].type=="radio"||formObj.elements[i].type=="checkbox"){
				formObj.elements[i].checked=false;
			}
		}
	}
}
function call(url,backFun,formid){//异步调用一个url链接
 var req = newXMLHttpRequest();
 if(formid){
 	url=getUrlParameter(url,formid);
 }
 req.onreadystatechange = getReadyStateHandler(req, backFun);
 req.open("POST",url, true);//异步
 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
 req.send();
}            
function callSynchronized(url,backFun,formid){//同步调用一个url链接
 var req = newXMLHttpRequest();
 if(formid){
 	url=getUrlParameter(url,formid);
 }
 req.onreadystatechange = getReadyStateHandler(req, backFun);
 req.open("POST",url, false);//同步，比较慢
 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
 req.send(null);
}
function postSynchronized(url,backFun,formid){//同步调用一个url链接  post提交

 var req = newXMLHttpRequest();
 req.onreadystatechange = getReadyStateHandler(req, backFun);
 req.open("POST",url, false);//同步，比较慢
 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
 req.send(encodeURI(encodeURI(getPostData(formid))));
}
function post(url,backFun,formid){//同步调用一个url链接 post 提交
 var req = newXMLHttpRequest();
 req.onreadystatechange = getReadyStateHandler(req, backFun);
 req.open("POST",url, false);//同步，比较慢
 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
 req.send(encodeURI(encodeURI(getPostData(formid))));
}
function callInstance(serviceName,arry,backFun){////异步调用一个类的实例
 var args="";
 for(ii=0;ii<arry.length;i++){
 	args+=arry[ii]+",";
 }
 if(args.length!=0){
 	args=args.substring(0,args.length-1);
 }
 var req = newXMLHttpRequest();
 req.onreadystatechange = getReadyStateHandler(req, backFun);
 if(args==""){
 	req.open("POST","/telecom/myServlet?serviceName="+serviceName, false);//同步，比较慢
 }else{
    req.open("POST","/telecom/myServlet?serviceName="+serviceName+"&args="+args, false);//同步，比较慢
 }
 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 req.send();
}            
function callSynchronizedInstance(serviceName,arry,backFun){//同步调用一个类的实例
 var args="";
 for(ii=0;ii<arry.length;ii++){
 	args+=arry[ii]+",";
 }
 if(args.length!=0){
 	args=args.substring(0,args.length-1);
 }
 var req = newXMLHttpRequest();
 req.onreadystatechange = getReadyStateHandler(req, backFun);
 if(args==""){
 	req.open("POST","/common/getValue.action?serviceName="+serviceName, false);//同步，比较慢
 }else{
    req.open("POST","/common/getValue.action?serviceName="+serviceName+"&args="+args, false);//同步，比较慢
 }
 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 req.send();
}

function AjaxObj(){//把XML一些信息封存在这个对象里
  this.xml=new Object();//返回XML
  this.root="";//根节点名称
  this.tableName="";//要填充的表格名称
  this.className="";//td的样式
  this.currentIndex=0;//当前行的索号
  this.inputType="";//如果为空没有选择框，checkbox,radio
  this.changeColor="yes";
  this.clickColor="";
  this.inputName="";
  this.pageInfo="";
  this.fenYe="fenYe";
  this.clickFirstRow=false;
  this.startRow=0;//已有行数的最大索引号
  this.lastCell="";//最后一格的内容
  this.menuId="";
  this.menuLabel="";
  this.menuValue="";
  this.nodeIndex=0;//当节点名字多个可以指定索引位置
}
AjaxObj.prototype.clearTab=function(tab,n){//清空表格
  var rowNum=tab.rows.length;
  var m=0;
  if(n!=""&&n!=null&&n!="undefined"){
    m=n;
  }
  while(rowNum>m){
    tab.deleteRow(rowNum-1);

    rowNum--;
  }
}
AjaxObj.prototype.getCurrentData=function(){//获取当前行的XML节点对象
	var items = this.xml.getElementsByTagName(this.root);
    return items[this.currentIndex];
}
AjaxObj.prototype.datas=function(i){//获取当前行的XML节点对象
    if(this.root==""){
        try{
			this.root=this.xml.getElementsByTagName("root")[0].firstChild.tagName;
		}catch(e){ 
			return null;
		}
    }
	var items = this.xml.getElementsByTagName(this.root);
    return items[i];
}
AjaxObj.prototype.length=function(){//获取当前行的XML节点对象
    if(this.root==""||this.root=="pageInfo"){
        try{
			this.root=this.xml.getElementsByTagName("root")[0].firstChild.tagName;
		}catch(e){ 
			return 0;
		}
    }
    if(this.root=="pageInfo"){
    	return 0;
    }
	var items = this.xml.getElementsByTagName(this.root);
    return items.length;
}
AjaxObj.prototype.createTable=function(prefix,firstIdValue,extraId){//把xml转为表格
	if(this.tableName.root) this.root=this.tableName.root;//根节点名称
	if(this.tableName.inputType) this.inputType=this.tableName.inputType;//如果为空没有选择框，checkbox,radio
	if(this.tableName.changeColor)  this.changeColor=this.tableName.changeColor;
	if(this.tableName.fenYe) this.fenYe=this.tableName.fenYe;
	if(this.tableName.clickFirstRow)  this.clickFirstRow=this.tableName.clickFirstRow;
	if(this.tableName.clickColor)  this.clickColor=this.tableName.clickColor;
	if(this.tableName.startRow)  this.startRow=this.tableName.startRow;//已有行数的最大索引号
	if(this.tableName.lastCell)  this.lastCell=this.tableName.lastCell;//最后一格的内容
	this.clearTab(this.tableName,1+this.startRow);
	if(this.root==""||this.root=="pageInfo"){//pageInfo是上次查询缓存下来的
	    try{
			this.root=this.xml.getElementsByTagName("root")[0].firstChild.tagName;
		}catch(e){
			return;
		}
	}
	if(this.root=="pageInfo") return;//空记录
	var items = this.xml.getElementsByTagName(this.root);
	/////////////////////////////
	if(!prefix){
	    for(var I = 0 ; I < items.length ; I++) {//把XML转为表格过程
	     var item = items[I];
	     var tr = this.tableName.tBodies[0].insertRow();
	     tr.className="out";
	     tr.align="center";
	     tr.id=I+"";
	     if(this.changeColor){
	     	 tr.attachEvent("onmouseover",overFun);//给tr加事件
	  		 tr.attachEvent("onmouseout",outFun);
	     }
	     if(this.inputType!="checkbox"&&this.inputType!="radio"){
	     	var i=0;//定义全局
	
		     for(i=0;i<this.tableName.rows[this.startRow].cells.length;i++){
		         var cellObj=this.tableName.rows[this.startRow].cells[i];
		         this.nodeIndex=0;
		         if(cellObj.jindex){
		         	this.nodeIndex=cellObj.jindex;
		         }
			     var cellValue="";
			     try{
			     	cellValue=item.getElementsByTagName(cellObj.jtext)[this.nodeIndex].firstChild.nodeValue;
			     }catch(e){}
		         var td=document.createElement("td");
		         td.className=this.className;
		         td.width=cellObj.width;
		         var conentAdd="";
		         if(cellObj.jadd){
		         	conentAdd=cellObj.jadd;
		         }
		         if(cellObj.jtext){
		             try{
		             	if(!cellObj.jselect){
		             	    if(!cellObj.jlink){
		             	        var jlength=cellObj.jlength;
		             	        if(jlength){
		        	 				if(jlength.indexOf(",")==-1){
		        	 					td.innerHTML=cellValue.substring(jlength);
		        	 				}else{
		        	 				    var len=jlength.indexOf(",");
		        	 				    if(cellValue.length>jlength.substring(len+1)){
		        	 						td.innerHTML=cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+conentAdd;
		        	 					}else{
		        	 						td.innerHTML=cellValue.substring(jlength.substring(0,len),jlength.substring(len+1));
		        	 					}
		        	 				}
		             	        }else{
		             	            td.innerHTML=cellValue+" ";//&=&amp;
		             	        }
		             	    }else{
		             	        var jlength=cellObj.jlength;
		             	        if(jlength){
		        	 				if(jlength.indexOf(",")==-1){
		        	 					td.innerHTML="<a href="+cellObj.jlink+">"+cellValue.substring(jlength)+"</a>";
		        	 				}else{
		        	 				    var len=jlength.indexOf(",");
		        	 				    if(cellValue.length>jlength.substring(len+1)){
		        	 						td.innerHTML="<a href="+cellObj.jlink+">"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+conentAdd+"</a>";
		        	 					}else{
		        	 						td.innerHTML="<a href="+cellObj.jlink+">"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+"</a>";
		        	 					}
		        	 				}
		             	        }else{
		             	            td.innerHTML="<a href="+cellObj.jlink+">"+cellValue+"</a>";
		             	        }
		             	    	
		             	    }
		             	}else{
		             	    var jlink=cellObj.jlink;
		             		callSynchronizedInstance("cn.ffcs.common.web.StaticDict."+cellObj.jselect,[cellValue],function(XML){
			                     if(!jlink){
			             	        td.innerHTML=$$(XML.responseXML,"str");
			                     }else{
			                     	td.innerHTML="<a href="+cellObj.jlink+">"+$$(XML.responseXML,"str")+"</a>";
			                     }
	                        });//获取select值
		             	}
		        	 }catch(e){
		        	  	 td.innerHTML="";
		        	 }
		         }else{
		         	if(this.lastCell!=""&&i==(this.tableName.rows[this.startRow].cells.length-1)){
	        	  	  td.innerHTML=this.lastCell;
	        	    }else{
	        	    	td.innerHTML="";
	        	    }
		         }
		         tr.appendChild(td);
		     }
	     }else{
	         var td=document.createElement("td");
		     td.className=this.className;
		     td.width=this.tableName.rows[this.startRow].cells[0].width;
		     var   myInputValue=item.getElementsByTagName(this.tableName.rows[this.startRow].cells[0].jtext)[0].firstChild.nodeValue;
		     if(this.inputName!=""){//设置选择框的ID
		     	td.innerHTML="<input type="+this.inputType+" name='"+this.inputName+"' value="+myInputValue+" >";
		     }else{
		     	td.innerHTML="<input type="+this.inputType+" name='"+this.tableName.rows[this.startRow].cells[0].jtext+"s' value="+myInputValue+" >";
		     }
		     tr.appendChild(td);
		     var i=1;//定义全局
		     for(i=1;i<this.tableName.rows[this.startRow].cells.length;i++){
		         var cellObj=this.tableName.rows[this.startRow].cells[i];
		         this.nodeIndex=0;
		         if(cellObj.jindex){
		         	this.nodeIndex=cellObj.jindex;
		         }
		         var cellValue="";
			     try{
			     	cellValue=item.getElementsByTagName(cellObj.jtext)[this.nodeIndex].firstChild.nodeValue;
			     }catch(e){}
		         var td=document.createElement("td");
		         td.className=this.className;//william
		         td.width=cellObj.width;
		         var conentAdd="";
		         if(cellObj.jadd){
		         	conentAdd=cellObj.jadd;
		         }
		         if(cellObj.jtext){
		             try{
		        	 	if(!cellObj.jselect){
		        	 		if(!cellObj.jlink){
		        	 		    var jlength=cellObj.jlength;
		             	        if(jlength){
		             	            if(jlength.indexOf(",")==-1){
		        	 					td.innerHTML=cellValue.substring(jlength);
		        	 				}else{
		        	 				    var len=jlength.indexOf(",");
		        	 					if(cellValue.length>jlength.substring(len+1)){
		        	 						td.innerHTML=cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+conentAdd;
		        	 					}else{
		        	 						td.innerHTML=cellValue.substring(jlength.substring(0,len),jlength.substring(len+1));
		        	 					}
		        	 				}
		             	        }else{
		             	            td.innerHTML=cellValue+" ";//&=&amp;
		             	        }
		             	    }else{
		             	    	var jlength=cellObj.jlength;
		             	        if(jlength){
		        	 				if(jlength.indexOf(",")==-1){
		        	 					td.innerHTML="<a href="+cellObj.jlink+">"+cellValue.substring(jlength)+"</a>";
		        	 				}else{
		        	 				    var len=jlength.indexOf(",");
		        	 				    if(cellValue.length>jlength.substring(len+1)){
		        	 						td.innerHTML="<a href="+cellObj.jlink+">"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+conentAdd+"</a>";
		        	 					}else{
		        	 						td.innerHTML="<a href="+cellObj.jlink+">"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+"</a>";
		        	 					}
		        	 				}
		             	        }else{
		             	            td.innerHTML="<a href="+cellObj.jlink+">"+cellValue+"</a>";
		             	        }
		             	    }
		             	}else{
		             	    var jlink=cellObj.jlink;
		             		callSynchronizedInstance("cn.ffcs.common.web.StaticDict."+cellObj.jselect,[cellValue],function(XML){
			                     if(!jlink){
			             	        td.innerHTML=$$(XML.responseXML,"str");
			                     }else{
			                     	td.innerHTML="<a href="+cellObj.jlink+">"+$$(XML.responseXML,"str")+"</a>";
			                     }
	                        });//获取select值
		             	}
		        	 }catch(e){
		        	    td.innerHTML="";
		        	 }
		         }else{
		         	if(this.lastCell!=""&&i==(this.tableName.rows[this.startRow].cells.length-1)){
	        	  	  td.innerHTML=this.lastCell;
	        	    }else{
	        	    	td.innerHTML="";
	        	    }
		         }
		         tr.appendChild(td);
		     }
	     }
	   }
   }else{//////////////////////////////////////////////////////////////////////有加前缀开始
       for(var I = 0 ; I < items.length ; I++) {//把XML转为表格过程
	     var item = items[I];
	     var tr = this.tableName.tBodies[0].insertRow();
	     tr.className="out";
	     tr.align="center";
	     tr.id=I+"";
	     if(this.changeColor){
	     	 tr.attachEvent("onmouseover",overFun);//给tr加事件
	  		 tr.attachEvent("onmouseout",outFun);
	     }
	     if(this.inputType!="checkbox"&&this.inputType!="radio"){
	     	var i=0;//定义全局
	
		     for(i=0;i<this.tableName.rows[this.startRow].cells.length;i++){
		         this.nodeIndex=0;
		         if(cellObj.jindex){
		         	this.nodeIndex=cellObj.jindex;
		         }
		         var cellValue="";
			     try{
			     	cellValue=item.getElementsByTagName(cellObj.jtext)[this.nodeIndex].firstChild.nodeValue;
			     }catch(e){}
		         var cellObj=this.tableName.rows[this.startRow].cells[i];
		         var td=document.createElement("td");
		         td.className=this.className;
		         td.width=cellObj.width;
		         var conentAdd="";
		         if(cellObj.jadd){
		         	conentAdd=cellObj.jadd;
		         }
		         if(cellObj.jtext){
		             var jname="";//id转name
		             if(cellObj.jname){
		                try{
		             		jname=item.getElementsByTagName(cellObj.jname)[0].firstChild.nodeValue;//id转名字
		             	}catch(e){}
		             	if(jname.length>6){
	             			jname=jname.substring(0,6)+"...";
	             	    }
		             }
		             try{
		             	if(!cellObj.jselect){
		             	    if(!cellObj.jlink){
		             	        var jlength=cellObj.jlength;
		             	        if(jlength){
		        	 				if(jlength.indexOf(",")==-1){
		        	 					td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue.substring(jlength)+"'>"+cellValue.substring(jlength);
		        	 				}else{
		        	 				    var len=jlength.indexOf(",");
		        	 				    if(cellValue.length>jlength.substring(len+1)){
		        	 						td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+"'>"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+conentAdd;
		        	 					}else{
		        	 						td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+"'>"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1));
		        	 					}
		        	 				}
		             	        }else{
		             	            if(!jname){
		             	            	td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+cellValue+" ";//&=&amp;
		             	            }else{
		             	            	td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+jname;//&=&amp;
		             	            }
		             	        }
		             	    }else{
		             	        if(!jname){
		             	    		td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+"<a href="+cellObj.jlink+">"+cellValue+"</a>";
		             	        }else{
		             	        	td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+"<a href="+cellObj.jlink+">"+jname+"</a>";
		             	        }
		             	    }
		             	}else{
		             	    var jlink=cellObj.jlink;
		             	    var tdValue="";
		             		callSynchronizedInstance("cn.ffcs.common.web.StaticDict."+cellObj.jselect,[cellValue],function(XML){
			                     if(!jlink){
			             	        td.innerHTML=$$(XML.responseXML,"str");
			                     }else{
			                     	td.innerHTML="<a href="+cellObj.jlink+">"+$$(XML.responseXML,"str")+"</a>";
			                     }
	                        });//获取select值
	                        td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+tdValue;
		             	}
		        	 }catch(e){
		        	  	 td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value=''>";
		        	 }
		         }else{
		         	if(this.lastCell!=""&&i==(this.tableName.rows[this.startRow].cells.length-1)){
	        	  	  td.innerHTML=this.lastCell;
	        	    }else{
	        	    	td.innerHTML="";
	        	    }
		         }
		         tr.appendChild(td);
		     }
	     }else{
	         var td=document.createElement("td");
		     td.className=this.className;
		     td.width=this.tableName.rows[this.startRow].cells[0].width;
		     var   myInputValue=item.getElementsByTagName(this.tableName.rows[this.startRow].cells[0].jtext)[0].firstChild.nodeValue;
		     if(this.inputName!=""){//设置选择框的ID
		        if(!firstIdValue){
		     		td.innerHTML="<input type='hidden' name='"+prefix+"."+this.tableName.rows[this.startRow].cells[0].jtext+"s'"+"value='"+myInputValue+"'>"+"<input type="+this.inputType+" name='"+this.inputName+"' value="+myInputValue+" >";
		        }else{
		        	td.innerHTML="<input type='hidden' name='"+prefix+"."+this.tableName.rows[this.startRow].cells[0].jtext+"s'"+"value='"+myInputValue+"'>"+"<input type="+this.inputType+" name='"+this.inputName+"' value="+item.getElementsByTagName(firstIdValue)[0].firstChild.nodeValue+" >";
		        }
		     }else{
		        if(!firstIdValue){
		     		td.innerHTML="<input type='hidden' name='"+prefix+"."+this.tableName.rows[this.startRow].cells[0].jtext+"s'"+"value='"+myInputValue+"'>"+"<input type="+this.inputType+" name='"+this.tableName.rows[this.startRow].cells[0].jtext+"s' value="+myInputValue+" >";
		        }else{
		        	td.innerHTML="<input type='hidden' name='"+prefix+"."+this.tableName.rows[this.startRow].cells[0].jtext+"s'"+"value='"+myInputValue+"'>"+"<input type="+this.inputType+" name='"+this.tableName.rows[this.startRow].cells[0].jtext+"s' value="+item.getElementsByTagName(firstIdValue)[0].firstChild.nodeValue+" >";
		        }
		     }
		     tr.appendChild(td);
		     if(extraId){
		     	var td=document.createElement("td");
		     	td.style.display="none";
		     	if(this.inputName!=""){//设置选择框的ID
			        if(!firstIdValue){
			     		td.innerHTML="<input type='hidden' name='"+prefix+"."+extraId+"s' value='"+myInputValue+"'>";
			        }else{
			        	td.innerHTML="<input type='hidden' name='"+prefix+"."+extraId+"s' value="+item.getElementsByTagName(firstIdValue)[0].firstChild.nodeValue+" >";
			        }
			    }else{
			        if(!firstIdValue){
			     		td.innerHTML="<input type='hidden' name='"+prefix+"."+extraId+"s'"+"value='"+myInputValue+"' >";
			        }else{
			        	td.innerHTML="<input type='hidden' name='"+prefix+"."+extraId+"s' value="+item.getElementsByTagName(firstIdValue)[0].firstChild.nodeValue+" >";
			        }
			     }
		     	tr.appendChild(td);
		     }
		     var i=1;//定义全局
		     for(i=1;i<this.tableName.rows[this.startRow].cells.length;i++){
		         this.nodeIndex=0;
		         if(cellObj.jindex){
		         	this.nodeIndex=cellObj.jindex;
		         }
		         var cellValue="";
			     try{
			     	cellValue=item.getElementsByTagName(cellObj.jtext)[this.nodeIndex].firstChild.nodeValue;
			     }catch(e){}
		         var cellObj=this.tableName.rows[this.startRow].cells[i];
		         var td=document.createElement("td");
		         td.className=this.className;//william
		         td.width=cellObj.width;
		         var jname="";//id转name
		         var conentAdd="";
		         if(cellObj.jadd){
		         	conentAdd=cellObj.jadd;
		         }
	             if(cellObj.jname){
	                try{
	             		jname=item.getElementsByTagName(cellObj.jname)[0].firstChild.nodeValue;//id转名字
	             	}catch(e){}
	             	if(jname.length>6){
	             		jname=jname.substring(0,6)+"...";
	             	}
	             }
		         if(cellObj.jtext){
		             try{
		             	if(!cellObj.jselect){
		             	    if(!cellObj.jlink){
		             	        var jlength=cellObj.jlength;
		             	        if(jlength){
		        	 				if(jlength.indexOf(",")==-1){
		        	 					td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue.substring(jlength)+"'>"+cellValue.substring(jlength);
		        	 				}else{
		        	 				    var len=jlength.indexOf(",");
		        	 					if(cellValue.length>jlength.substring(len+1)){
		        	 						td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+"'>"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+conentAdd;
		        	 					}else{
		        	 						td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1))+"'>"+cellValue.substring(jlength.substring(0,len),jlength.substring(len+1));
		        	 					}
		        	 				}
		             	        }else{
		             	            if(!jname){
		             	            	td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+cellValue+" ";//&=&amp;
		             	            }else{
		             	            	td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+jname+" ";//&=&amp;
		             	            }
		             	        }
		             	    }else{
		             	        if(!jname){
		             	    		td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+"<a href="+cellObj.jlink+">"+cellValue+"</a>";
		             	        }else{
		             	        	td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+"<a href="+cellObj.jlink+">"+jname+"</a>";
		             	        }
		             	    }
		             	}else{
		             	    var jlink=cellObj.jlink;
		             	    var tdValue="";
		             		callSynchronizedInstance("cn.ffcs.common.web.StaticDict."+cellObj.jselect,[cellValue],function(XML){
			                     if(!jlink){
			             	        td.innerHTML=$$(XML.responseXML,"str");
			                     }else{
			                     	td.innerHTML="<a href="+cellObj.jlink+">"+$$(XML.responseXML,"str")+"</a>";
			                     }
	                        });//获取select值
	                        td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value='"+cellValue+"'>"+tdValue;
		             	}
		        	 }catch(e){
		        	  	 td.innerHTML="<input type='hidden' name='"+prefix+"."+cellObj.jtext+"s'"+"value=''>";
		        	 }
		         }else{
		         	if(this.lastCell!=""&&i==(this.tableName.rows[this.startRow].cells.length-1)){
	        	  	  td.innerHTML=this.lastCell;
	        	    }else{
	        	    	td.innerHTML="";
	        	    }
		         }
		         tr.appendChild(td);
		     }
	     }
	   }
   }
   ///////////////////////////////
   if(this.clickFirstRow==true||this.clickFirstRow=="true"){
   		if(this.tableName.rows.length>(1+this.startRow)){
   			this.tableName.rows[1+this.startRow].cells[0].click();//选择第一行
   		}
   }
   try{//分页
        if(this.fenYe=="") return;
		this.pageInfo=this.xml.getElementsByTagName("pageInfo")[0].firstChild.nodeValue;
		document.getElementById(this.fenYe).pageInfo=this.pageInfo;
		this.pageInfo=getFenYe(this.fenYe);
   }catch(e){}
}
function setCurrentData(ajaxObj){//当前行值
    try{
	    if(event.srcElement.tagName!="TD"&&event.srcElement.type!="radio"&&event.srcElement.type!="checkbox"){
	        if(event.srcElement.parentElement.tagName=="TD"&&event.srcElement.type!="radio"&&event.srcElement.type!="checkbox"){
	    		event.srcElement.parentElement.click();
	    	}else{
	    		event.srcElement.parentElement.parentElement.click();
	    	}
	    	return;
	    }
    }catch(e){}
	if(event.srcElement.tagName!="TD"&&event.srcElement.type!="radio"&&event.srcElement.type!="checkbox")return;
	if((event.srcElement.parentElement.rowIndex)<=(0+ajaxObj.startRow))return;
	//for(i=1;i<event.srcElement.parentElement.parentElement.rows.length;i++){
		//event.srcElement.parentElement.parentElement.rows[i].bgColor="#FFFFFF";
	//}
	//event.srcElement.parentElement.bgColor="yellow";
	if(event.srcElement.tagName=="TD"){
		//ajaxObj.currentIndex=event.srcElement.parentElement.rowIndex-(1+ajaxObj.startRow);
		ajaxObj.currentIndex=parseInt(event.srcElement.parentElement.id);
		if(ajaxObj.inputType=="checkbox"||ajaxObj.inputType=="radio"){
		    if(event.srcElement.parentElement.cells[0].firstChild.checked==false||ajaxObj.inputType=="radio"){
				event.srcElement.parentElement.cells[0].firstChild.checked=true;
			}else{
			    event.srcElement.parentElement.cells[0].firstChild.checked=false;
			}
		}
	}else{
		//ajaxObj.currentIndex=event.srcElement.parentElement.parentElement.rowIndex-(1+ajaxObj.startRow);
		ajaxObj.currentIndex=parseInt(event.srcElement.parentElement.parentElement.id);
	}
	if(ajaxObj.clickColor){//选中背景色
		for(i=1+ajaxObj.startRow;i<ajaxObj.tableName.rows.length;i++){
			ajaxObj.tableName.rows[i].className="out";
		}
		if(event.srcElement.parentElement.tagName=="TR"){
			event.srcElement.parentElement.className="clickColor";
		}else if(event.srcElement.parentElement.tagName=="TD"){
			event.srcElement.parentElement.parentElement.className="clickColor";
		}
	}
}
function overFun(){//光标表格经过颜色
	if(event.srcElement.tagName!="TD")return;
	if(event.srcElement.parentElement.className=='out'){
		event.srcElement.parentElement.className='over';
	}
}
function outFun(){//光标表格离开颜色
    if(event.srcElement.parentElement.className=='over'){
		event.srcElement.parentElement.className='out';
	}
}
function clearTab(tab,n){//清空表格
  var rowNum=tab.rows.length;
  var m=0;
  if(n!=""&&n!=null&&n!="undefined"){
    m=n;
  }
  while(rowNum>m){
    tab.deleteRow(rowNum-1);

    rowNum--;
  }
}
AjaxObj.prototype.createMenu=function(){
    if(this.root==""||this.root=="pageInfo"){
        try{
			this.root=this.xml.getElementsByTagName("root")[0].firstChild.tagName;
		}catch(e){
			return;
		}
    }
    if(this.root=="pageInfo") return;
	var items = this.xml.getElementsByTagName(this.root);
	if(!$(this.menuId).property||!$(this.menuId).labelProperty){
		return;
	}
	try{
	    for (var I = 0 ; I < items.length ; I++) {
		    var item = items[I];
	        var option=document.createElement("option");
	    	option.value=item.getElementsByTagName($(this.menuId).property)[0].firstChild.nodeValue;
	    	option.text=item.getElementsByTagName($(this.menuId).labelProperty)[0].firstChild.nodeValue;
	    	$(this.menuId).add(option);
	    }
    }catch(e){}
}
//document.write('<script language="JavaScript" src=/cp/common/sorttable.js charset="gb2312"></script>
		//');
function clickFirsCell(){
	if(event.srcElement.parentElement.tagName=="TR"){
		event.srcElement.parentElement.cells[0].lastChild.checked=true;
	}
}
function createTr(tableName,formid,prefix,firstType,idValue1,idValue2,extraId){
    if(idValue1&&!idValue2){
    	idValue2=idValue1;
    }
    if(!idValue1&&!idValue2){
    	idValue1="";
    	idValue2="";
    }
	var formObj="";
    if(document.getElementById(formid)){
    	formObj=document.getElementById(formid)
    }else{
        formObj=document[formid];
    }
    if(!formObj)return;//表单对象不存在则返回
    var tr=tableName.tBodies[0].insertRow();
	tr.className="out";
   	tr.attachEvent("onmouseover",window.dialogArguments.overFun);//给tr加事件
  	tr.attachEvent("onmouseout",window.dialogArguments.outFun);
  	tr.attachEvent("onclick",window.dialogArguments.clickFirsCell);
   	tr.align="center";
   	tr.style.display="";
   	var startCell=0;
   	if(firstType){
   		startCell=1;
   		var td0=window.dialogArguments.document.createElement("td");
   		td0.width=tableName.rows[0].cells[0].width;
   		td0.innerHTML="<input type='hidden' name='"+prefix+"."+tableName.rows[0].cells[0].jtext+"s' value='"+idValue1+"'>"+"<input type='"+firstType+"' name='"+tableName.rows[0].cells[0].jtext+"s'  value='"+idValue2+"'>";
   		tr.appendChild(td0);
   	}
   	if(extraId){
   		var td0=window.dialogArguments.document.createElement("td");
   		td0.style.display="none";
   		td0.innerHTML="<input type='hidden' name='"+prefix+"."+extraId+"s'  value='"+idValue2+"'>";
   		tr.appendChild(td0);
   	}
   	for(i=startCell;i<tableName.rows[0].cells.length;i++){
   		var td=window.dialogArguments.document.createElement("td");
   		td.width=tableName.rows[0].cells[i].width;
   		if(tableName.rows[0].cells[i].jtext){
   			var name=tableName.rows[0].cells[i].jtext;
   			var names=name+"s";
   			var obj;
   			if(formObj[name]){
   				obj=formObj[name];
   			}else if(document.getElementById(name)){
   				obj=document.getElementById(name);
   			}else{
   				td.innerHTML="未找到属性";
   				continue;
   			}
   			if(obj.type){
	   			if(obj.type=="text"||obj.type=="textarea"||obj.type=="hidden"){
	   			    if(tableName.rows[0].cells[i].jlength){
	   			        var jlength=tableName.rows[0].cells[i].jlength;
	   			     	var len=jlength.indexOf(",");
	   			     	if(tableName.rows[0].cells[i].jnext){
	   			     	    if(document.all[obj.sourceIndex-1].value.length>6){
	   			     	    	document.all[obj.sourceIndex-1].value=document.all[obj.sourceIndex-1].value.substring(0,5)+"...";
	   			     	    }
	   			     		td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+document.all[obj.sourceIndex-1].value.substring(jlength.substring(0,len),jlength.substring(len+1));
	   			     	}else{
		             		td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+obj.value.substring(jlength.substring(0,len),jlength.substring(len+1));
	   				    }
	   				    if(obj.value.length>len){
	   				    	td.innerHTML+="";/////////////////////
	   				    }
	   				}else{
	   				    if(tableName.rows[0].cells[i].jnext){
	   				        if(document.all[obj.sourceIndex-1].value.length>6){
	   			     	    	document.all[obj.sourceIndex-1].value=document.all[obj.sourceIndex-1].value.substring(0,5)+"...";
	   			     	    }
	   						td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+document.all[obj.sourceIndex-1].value;
	   				    }else{
	   				    	td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+obj.value;
	   				    }
	   				}
	   			}else if(obj.type=="radio"){
	   				if(obj.checked==true){
	   					td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"'  value='"+obj.value+"' >"+obj.value;
	   				}
	   			}else if(obj.type=="select-one"){
	   			    td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"'  value='9' >";
	   				for(j=0;j<obj.options.length;j++){
	   					if(obj.options[j].selected==true){
	   						td.innerHTML="<input type='hidden' name='"+prefix+"."+names+"'  value='"+obj.value+"' >"+obj.options[j].innerHTML;
	   					   continue;;
	   					}
	   				}
	   			}
   			}
   		}else{
   			td.innerHTML="未设置jtext";
   			continue;
   		}
   		tr.appendChild(td);
   	}
   // alert(tr.innerHTML);
}	
function updateTr(tr,formid,prefix,firstType){
	var formObj="";
    if(document.getElementById(formid)){
    	formObj=document.getElementById(formid)
    }else{
        formObj=document[formid];
    }
    if(!formObj)return;//表单对象不存在则返回
   	var startCell=0;
   	var tableName=tr.parentElement.parentElement;
   	if(firstType){
   		startCell=1;
   		//tr.cells[0].innerHTML="<input type='hidden' name='"+prefix+"."+tableName.rows[0].cells[0].jtext+"s' >"+"<input type='"+firstType+"' name='"+tableName.rows[0].cells[0].jtext+"s' >";
   	}
   	for(i=startCell;i<tableName.rows[0].cells.length;i++){
   		if(tableName.rows[0].cells[i].jtext){
   			var name=tableName.rows[0].cells[i].jtext;
   			var names=name+"s";
   			var obj;
   			if(formObj[name]){
   				obj=formObj[name];
   			}else if(document.getElementById(name)){
   				obj=document.getElementById(name);
   			}else{
   				td.innerHTML="未找到属性";
   				continue;
   			}
   			if(obj.type){
	   			if(obj.type=="text"||obj.type=="textarea"||obj.type=="hidden"){
	   			    if(tableName.rows[0].cells[i].jlength){
	   			        var jlength=tableName.rows[0].cells[i].jlength;
	   			     	var len=jlength.indexOf(",");
	   			     	if(tableName.rows[0].cells[i].jnext){
	   			     	    if(document.all[obj.sourceIndex-1].value.length>6){
	   			     	    	document.all[obj.sourceIndex-1].value=document.all[obj.sourceIndex-1].value.substring(0,5)+"...";
	   			     	    }
	   			     		tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+document.all[obj.sourceIndex-1].value.substring(jlength.substring(0,len),jlength.substring(len+1));
	   			     	}else{
	   						tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+obj.value.substring(jlength.substring(0,len),jlength.substring(len+1));
	   			        }
	   			        if(obj.value.length>len){
	   				    	tr.cells[i].innerHTML+="";//////////////////////////
	   				    }
	   			    }else{
	   			        if(tableName.rows[0].cells[i].jnext){
	   			            if(document.all[obj.sourceIndex-1].value.length>6){
	   			     	    	document.all[obj.sourceIndex-1].value=document.all[obj.sourceIndex-1].value.substring(0,5)+"...";
	   			     	    }
	   			        	tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+document.all[obj.sourceIndex-1].value;
	   			        }else{
	   			    		tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"' value='"+obj.value+"' >"+obj.value;
	   			        }
	   			    } 
	   			}else if(obj.type=="radio"){
	   				if(obj.checked==true){
	   					tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"'  value='"+obj.value+"' >"+obj.value;
	   				}
	   			}else if(obj.type=="select-one"){
	   			    tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"'  value='9' >";
	   				for(j=0;j<obj.options.length;j++){
	   					if(obj.options[j].selected==true){
	   						tr.cells[i].innerHTML="<input type='hidden' name='"+prefix+"."+names+"'  value='"+obj.value+"' >"+obj.options[j].innerHTML;
	   					   break;;
	   					}
	   				}
	   				continue;
	   			}
   			}
   		}else{
   			tr.cells[i].innerHTML="未设置jtext";
   			continue;
   		}
   	}
   	
  // alert(tr.innerHTML);
}	
function selectRow(){
   		if(event.srcElement.tagName=="TD"){
   			if(event.srcElement.parentElement.rowIndex==0){
   				return;
   			}
   			try{
   			    var obj=event.srcElement.parentElement.cells[0].firstChild;
   				if(obj.type.toLowerCase()=="radio"){
   					obj.checked=true;
   				}
   				if(obj.type.toLowerCase()=="checkbox"){
   					if(obj.checked){
   						obj.checked=false;
   					}else{
   						obj.checked=true;
   					}
   				}
   			}catch(e){}
   		}
}
function initBtn(btnstr){
    btnstr=","+btnstr+",";
	var obj=document.getElementsByName("mybutton");
	for(i=0;i<obj.length;i++){
		if(btnstr.indexOf(","+obj[i].id.substring(1)+",")==-1){
			obj[i].disabled=true;
		}
	}
}
/*字段ID与名字的转换*/
function initlabel(){
	var obj=document.getElementsByName("chlabel");
	for(i=0;i<obj.length;i++){
	    var id=obj[i].innerHTML.trim();
		callSynchronizedInstance("cn.ffcs.common.web.StaticDict."+obj[i].jselect,[id],function(XML){
	        obj[i].innerHTML=$$(XML.responseXML,"str");
         });
	}
}